using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using SJVars;
using Spacejock;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;
using yWriter6.My.Resources;

namespace yWriter6
{
	[DesignerGenerated]
	internal class frmWordCount : Form
	{
		private IContainer components;

		public ToolTip ToolTip1;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdOK")]
		private Button _cmdOK;

		[CompilerGenerated]
		[AccessedThroughProperty("_ListView1_ColumnHeader_1")]
		private ColumnHeader __ListView1_ColumnHeader_1;

		[CompilerGenerated]
		[AccessedThroughProperty("_ListView1_ColumnHeader_2")]
		private ColumnHeader __ListView1_ColumnHeader_2;

		[CompilerGenerated]
		[AccessedThroughProperty("ListView1")]
		private ListView _ListView1;

		[CompilerGenerated]
		[AccessedThroughProperty("lblInfo")]
		private Label _lblInfo;

		[CompilerGenerated]
		[AccessedThroughProperty("cmdCopy")]
		private Button _cmdCopy;

		private clsListViewSort lvwColumnSorter;

		public virtual Button cmdOK
		{
			[CompilerGenerated]
			get
			{
				return _cmdOK;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdOK_Click;
				Button cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click -= value2;
				}
				_cmdOK = value;
				cmdOK = _cmdOK;
				if (cmdOK != null)
				{
					cmdOK.Click += value2;
				}
			}
		}

		[field: AccessedThroughProperty("_ListView1_ColumnHeader_1")]
		public virtual ColumnHeader _ListView1_ColumnHeader_1
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		[field: AccessedThroughProperty("_ListView1_ColumnHeader_2")]
		public virtual ColumnHeader _ListView1_ColumnHeader_2
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public virtual ListView ListView1
		{
			[CompilerGenerated]
			get
			{
				return _ListView1;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				ColumnClickEventHandler value2 = ListView1_ColumnClick;
				EventHandler value3 = ListView1_SelectedIndexChanged;
				ListView listView = _ListView1;
				if (listView != null)
				{
					listView.ColumnClick -= value2;
					listView.SelectedIndexChanged -= value3;
				}
				_ListView1 = value;
				listView = _ListView1;
				if (listView != null)
				{
					listView.ColumnClick += value2;
					listView.SelectedIndexChanged += value3;
				}
			}
		}

		[field: AccessedThroughProperty("lblInfo")]
		public virtual Label lblInfo
		{
			get;
			[MethodImpl(MethodImplOptions.Synchronized)]
			set;
		}

		public virtual Button cmdCopy
		{
			[CompilerGenerated]
			get
			{
				return _cmdCopy;
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			[CompilerGenerated]
			set
			{
				EventHandler value2 = cmdCopy_Click;
				Button cmdCopy = _cmdCopy;
				if (cmdCopy != null)
				{
					cmdCopy.Click -= value2;
				}
				_cmdCopy = value;
				cmdCopy = _cmdCopy;
				if (cmdCopy != null)
				{
					cmdCopy.Click += value2;
				}
			}
		}

		[DebuggerNonUserCode]
		public frmWordCount()
		{
			base.FormClosing += frmWordCount_FormClosing;
			base.Load += frmWordCount_Load;
			lvwColumnSorter = new clsListViewSort();
			InitializeComponent();
		}

		[DebuggerNonUserCode]
		protected override void Dispose(bool Disposing)
		{
			if (Disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(Disposing);
		}

		[System.Diagnostics.DebuggerStepThrough]
		private void InitializeComponent()
		{
			components = new System.ComponentModel.Container();
			ToolTip1 = new System.Windows.Forms.ToolTip(components);
			cmdOK = new System.Windows.Forms.Button();
			ListView1 = new System.Windows.Forms.ListView();
			_ListView1_ColumnHeader_1 = new System.Windows.Forms.ColumnHeader();
			_ListView1_ColumnHeader_2 = new System.Windows.Forms.ColumnHeader();
			lblInfo = new System.Windows.Forms.Label();
			cmdCopy = new System.Windows.Forms.Button();
			SuspendLayout();
			cmdOK.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			cmdOK.BackColor = System.Drawing.SystemColors.Control;
			cmdOK.Cursor = System.Windows.Forms.Cursors.Default;
			cmdOK.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdOK.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdOK.Location = new System.Drawing.Point(367, 463);
			cmdOK.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdOK.Name = "cmdOK";
			cmdOK.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdOK.Size = new System.Drawing.Size(66, 35);
			cmdOK.TabIndex = 1;
			cmdOK.Text = "OK";
			cmdOK.UseVisualStyleBackColor = true;
			ListView1.AllowColumnReorder = true;
			ListView1.Anchor = (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);
			ListView1.BackColor = System.Drawing.SystemColors.Window;
			ListView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2]
			{
				_ListView1_ColumnHeader_1,
				_ListView1_ColumnHeader_2
			});
			ListView1.Font = new System.Drawing.Font("Segoe UI", 10f);
			ListView1.ForeColor = System.Drawing.SystemColors.WindowText;
			ListView1.FullRowSelect = true;
			ListView1.GridLines = true;
			ListView1.LabelEdit = true;
			ListView1.Location = new System.Drawing.Point(14, 15);
			ListView1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			ListView1.Name = "ListView1";
			ListView1.Size = new System.Drawing.Size(419, 439);
			ListView1.TabIndex = 0;
			ListView1.UseCompatibleStateImageBehavior = false;
			ListView1.View = System.Windows.Forms.View.Details;
			_ListView1_ColumnHeader_1.Text = "Word";
			_ListView1_ColumnHeader_1.Width = 170;
			_ListView1_ColumnHeader_2.Text = "Count";
			_ListView1_ColumnHeader_2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
			_ListView1_ColumnHeader_2.Width = 118;
			lblInfo.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			lblInfo.BackColor = System.Drawing.SystemColors.Control;
			lblInfo.Cursor = System.Windows.Forms.Cursors.Default;
			lblInfo.Font = new System.Drawing.Font("Segoe UI", 10f);
			lblInfo.ForeColor = System.Drawing.SystemColors.ControlText;
			lblInfo.Location = new System.Drawing.Point(19, 468);
			lblInfo.Name = "lblInfo";
			lblInfo.RightToLeft = System.Windows.Forms.RightToLeft.No;
			lblInfo.Size = new System.Drawing.Size(268, 24);
			lblInfo.TabIndex = 2;
			lblInfo.Text = "Label1";
			cmdCopy.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			cmdCopy.BackColor = System.Drawing.SystemColors.Control;
			cmdCopy.Cursor = System.Windows.Forms.Cursors.Default;
			cmdCopy.Font = new System.Drawing.Font("Segoe UI", 10f);
			cmdCopy.ForeColor = System.Drawing.SystemColors.ControlText;
			cmdCopy.Location = new System.Drawing.Point(294, 463);
			cmdCopy.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			cmdCopy.Name = "cmdCopy";
			cmdCopy.RightToLeft = System.Windows.Forms.RightToLeft.No;
			cmdCopy.Size = new System.Drawing.Size(66, 35);
			cmdCopy.TabIndex = 1;
			cmdCopy.Text = "Copy";
			cmdCopy.UseVisualStyleBackColor = true;
			base.AutoScaleDimensions = new System.Drawing.SizeF(7f, 17f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			BackColor = System.Drawing.SystemColors.Control;
			base.ClientSize = new System.Drawing.Size(450, 503);
			base.Controls.Add(cmdCopy);
			base.Controls.Add(cmdOK);
			base.Controls.Add(ListView1);
			base.Controls.Add(lblInfo);
			Cursor = System.Windows.Forms.Cursors.Default;
			DoubleBuffered = true;
			Font = new System.Drawing.Font("Segoe UI", 10f);
			base.Location = new System.Drawing.Point(3, 22);
			base.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
			MinimumSize = new System.Drawing.Size(416, 535);
			base.Name = "frmWordCount";
			RightToLeft = System.Windows.Forms.RightToLeft.No;
			base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			Text = "Word Usage Counts";
			ResumeLayout(false);
		}

		private void cmdOK_Click(object eventSender, EventArgs eventArgs)
		{
			Hide();
		}

		private void frmWordCount_FormClosing(object sender, FormClosingEventArgs e)
		{
			cDelay.DoEvents();
		}

		private void frmWordCount_Load(object eventSender, EventArgs eventArgs)
		{
			base.Icon = Resources.yWriter5_Ico;
			if (Operators.CompareString(clsShared.cLang.CurrentLanguage, "English", TextCompare: false) != 0)
			{
				clsShared.cLang.TranslateForm(this);
			}
			clsShared.cFormFont.SetFormFont(this, clsShared.cSettings.sGet("FormFont", modVariables.DefaultUIFont.Name), clsShared.cSettings.sGet("UIFontSize", modVariables.DefaultUIFont.Size));
		}

		public void FillForm(Collection colHash, bool WithSort)
		{
			//Discarded unreachable code: IL_011e, IL_0135, IL_0140, IL_0150, IL_01aa, IL_01ac, IL_01c0, IL_01e2
			int num = default(int);
			int num4 = default(int);
			try
			{
				ProjectData.ClearProjectError();
				num = 2;
				int num2 = 2;
				clsShared.cSubs.BusyMouse();
				num2 = 3;
				int count = colHash.Count;
				int num3 = default(int);
				for (int i = 1; i <= count; i++)
				{
					num2 = 4;
					object obj = colHash[i];
					HashRec hashRec = (obj != null) ? ((HashRec)obj) : default(HashRec);
					num2 = 5;
					ListViewItem listViewItem = ListView1.Items.Add(hashRec.Word);
					num2 = 6;
					listViewItem.SubItems.Add(Conversions.ToString(hashRec.Count));
					num2 = 7;
					num3 += hashRec.Count;
					num2 = 8;
				}
				num2 = 9;
				lblInfo.Text = "Total words: " + Conversions.ToString(num3) + " Unique: " + Conversions.ToString(ListView1.Items.Count);
				num2 = 10;
				if (WithSort)
				{
					num2 = 11;
					lvwColumnSorter.Order = SortOrder.Descending;
					num2 = 12;
					lvwColumnSorter.SortColumn = 1;
					num2 = 13;
					ListView1.ListViewItemSorter = lvwColumnSorter;
					num2 = 14;
					ListView1.Sort();
				}
				num2 = 15;
				clsShared.cSubs.NormalMouse();
			}
			catch (Exception obj2) when ((num != 0) & (num4 == 0))
			{
				ProjectData.SetProjectError(obj2);
				/*Error near IL_01e0: Could not find block for branch target IL_01ac*/;
			}
			if (num4 != 0)
			{
				ProjectData.ClearProjectError();
			}
		}

		private void ListView1_ColumnClick(object sender, ColumnClickEventArgs e)
		{
			if (e.Column == lvwColumnSorter.SortColumn)
			{
				if (lvwColumnSorter.Order == SortOrder.Ascending)
				{
					lvwColumnSorter.Order = SortOrder.Descending;
				}
				else
				{
					lvwColumnSorter.Order = SortOrder.Ascending;
				}
			}
			else
			{
				lvwColumnSorter.SortColumn = e.Column;
				lvwColumnSorter.Order = SortOrder.Ascending;
			}
			ListView1.Sort();
		}

		private void ListView1_SelectedIndexChanged(object sender, EventArgs e)
		{
		}

		private void cmdCopy_Click(object sender, EventArgs e)
		{
			StringBuilder stringBuilder = new StringBuilder();
			IEnumerator enumerator = default(IEnumerator);
			try
			{
				enumerator = ListView1.Items.GetEnumerator();
				while (enumerator.MoveNext())
				{
					ListViewItem listViewItem = (ListViewItem)enumerator.Current;
					try
					{
						stringBuilder.Append(listViewItem.Text + ",");
						stringBuilder.AppendLine(listViewItem.SubItems[1].Text);
					}
					catch (Exception ex)
					{
						ProjectData.SetProjectError(ex);
						Exception ex2 = ex;
						ProjectData.ClearProjectError();
					}
				}
			}
			finally
			{
				if (enumerator is IDisposable)
				{
					(enumerator as IDisposable).Dispose();
				}
			}
			Clipboard.Clear();
			Clipboard.SetText(stringBuilder.ToString());
		}
	}
}
